home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 2
/
Atari Mega Archive CD - Volume 2.iso
/
minix
/
up1510b.tgz
/
up1510b
/
src
/
kernel
/
stwini.c.D
< prev
next >
Wrap
Text File
|
1990-07-31
|
9KB
|
334 lines
*** /tmp/,RCSt1022356 Wed Jul 25 13:56:21 1990
--- stwini.c Mon Jul 23 22:46:35 1990
***************
*** 1,2 ****
! #ifdef ATARI_ST
/*
--- 1,2 ----
! #if (MACHINE == ATARI)
/*
***************
*** 4,5 ****
--- 4,8 ----
* on the Atari ST.
+ * If yor drive is an old Supra drive you perhaps want to compile
+ * using -DSUPRA. The code added with #ifdef SUPRA/#endif is taken
+ * from usenet and not verified (since I do not have such a drive)
*
***************
*** 14,15 ****
--- 17,24 ----
* | DISK_WRITE | device | proc nr | bytes | offset | buf ptr |
+ * |--------------------------------------------------------------|
+ * |SCATTERED_IO| device | proc nr | requests| | iov ptr |
+ #ifdef CLOCKS
+ * |------------+---------+---------+---------+---------+---------|
+ * | DISK_IOCTL | device | proc nr |func code| address | |
+ #endif
* ----------------------------------------------------------------
***************
*** 45,53 ****
! #include "../h/const.h"
! #include "../h/type.h"
! #include "../h/callnr.h"
! #include "../h/com.h"
! #include "../h/error.h"
! #include "const.h"
! #include "type.h"
#include "proc.h"
--- 54,58 ----
! #include "kernel.h"
! #include <minix/callnr.h>
! #include <minix/com.h>
#include "proc.h"
***************
*** 62,63 ****
--- 67,74 ----
+ #ifdef CLOCKS
+ #ifndef DISK_IOCTL
+ # define DISK_IOCTL TTY_IOCTL
+ #endif
+
+ #endif /* CLOCKS */
/* Parameters for the disk drive. */
***************
*** 64,66 ****
#define SECTOR_SIZE 512 /* physical sector size in bytes */
- #define NR_DRIVES 1 /* maximum number of drives */
#define MAX_MINOR (NR_DRIVES<<3)
--- 75,76 ----
***************
*** 79,81 ****
! FORWARD int hdcint();
--- 89,96 ----
! static int do_rdwt();
! static int do_xfer();
! static void cmdhead();
! static int cmdtail();
! static int poll();
! static void hdcint();
***************
*** 84,86 ****
*===========================================================================*/
! PUBLIC winchester_task()
{
--- 99,101 ----
*===========================================================================*/
! PUBLIC void winchester_task()
{
***************
*** 94,96 ****
/* read sector 0 of the drive and copy the partition info */
! pi[minor].pi_size = 1;
dmagrab(WINCHESTER, hdcint);
--- 109,111 ----
/* read sector 0 of the drive and copy the partition info */
! pi[minor].pi_size = 2;
dmagrab(WINCHESTER, hdcint);
***************
*** 107,109 ****
}
! pi[minor].pi_size = hi.hd_size;
}
--- 122,127 ----
}
! /* the next minor number is for the whole device */
! /* don't overwrite partition table; start at sector 1 */
! pi[minor].pi_start = 1;
! pi[minor].pi_size = hi.hd_size - SECTOR_SIZE;
}
***************
*** 134,135 ****
--- 152,157 ----
case DISK_WRITE: r = do_rdwt(&mess); break;
+ case SCATTERED_IO: r = do_vrdwt(&mess, do_rdwt); break;
+ #ifdef CLOCKS
+ case DISK_IOCTL: r = do_ioctl(&mess); break;
+ #endif /* CLOCKS */
default: r = EINVAL; break;
***************
*** 154,158 ****
register r, errors, count, rw, drive, minor;
! register long secnum;
register phys_bytes address;
- extern phys_bytes umap();
--- 176,179 ----
register r, errors, count, rw, drive, minor;
! register long secnum, avail;
register phys_bytes address;
***************
*** 178,183 ****
minor, rw == DISK_READ ? "read" : "write", secnum, count));
! if (pi[minor].pi_size - secnum < count)
! count = pi[minor].pi_size - secnum;
if (count <= 0)
! return(EOF);
secnum += pi[minor].pi_start;
--- 199,207 ----
minor, rw == DISK_READ ? "read" : "write", secnum, count));
! avail = pi[minor].pi_size - secnum;
! if (avail <= 0)
! return(0);
! if (avail < count)
! count = avail;
if (count <= 0)
! return(0);
secnum += pi[minor].pi_start;
***************
*** 201,202 ****
--- 225,231 ----
*===========================================================================*/
+
+ #ifdef SUPRA
+ #define PNK_DELAY 50 /* tunable */
+ #endif
+
PRIVATE int do_xfer(drive, address, sector, count, rw)
***************
*** 233,240 ****
r = cmdtail(drive, sector, count); /* command parameters */
IENABLE();
if (r == OK) {
dmacomm(wrbit | FDC | SCREG, count, HDC_DELAY);
! dmawdat(wrbit | FDC | HDC | A0, 0, HDC_DELAY);
! DMA->dma_mode = wrbit; /* needed? */
receive(HARDWARE, &mess); /* Wait for interrupt. */
s = dmardat(wrbit | FDC | HDC | A0, HDC_DELAY);
--- 262,277 ----
r = cmdtail(drive, sector, count); /* command parameters */
+ #ifndef SUPRA
IENABLE();
+ #endif
if (r == OK) {
+ #ifdef SUPRA
+ IENABLE();
+ #endif
dmacomm(wrbit | FDC | SCREG, count, HDC_DELAY);
! DMA->dma_mode = wrbit | FDC | HDC | A0;
! dmawcmd(0, wrbit);
receive(HARDWARE, &mess); /* Wait for interrupt. */
+ #ifdef SUPRA
+ IDISABLE();
+ #endif
s = dmardat(wrbit | FDC | HDC | A0, HDC_DELAY);
***************
*** 241,242 ****
--- 278,282 ----
if (s & HDC_CC) {
+ #ifdef SUPRA
+ if ((s & HDC_CC) != 2) /* 2: invalid cyl/no drive */
+ #endif
printf("hd: %s: drive=%d sector=%D status=0x%x\n",
***************
*** 248,249 ****
--- 288,293 ----
;
+ #ifdef SUPRA
+ for (s = 0; s< PNK_DELAY; s++) {} /* Guarantee interrupt is gone */
+ IENABLE(); /* re-enable normal interrupts */
+ #endif
return(r);
***************
*** 255,257 ****
! PRIVATE cmdhead(drive, cmd)
{
--- 299,303 ----
! PRIVATE void cmdhead(drive, cmd)
! int drive;
! int cmd;
{
***************
*** 258,261 ****
DMA->dma_mode = FDC | HDC;
! DMA->dma_data = (short)(((drive>>1)<<5) | (cmd&0x1F));
! DMA->dma_mode = FDC | HDC | A0;
}
--- 304,306 ----
DMA->dma_mode = FDC | HDC;
! dmawcmd((short)(((drive>>1)<<5) | (cmd&0x1F)), FDC | HDC | A0);
}
***************
*** 262,265 ****
! PRIVATE cmdtail(drive, sector, count)
long sector;
{
--- 307,312 ----
! PRIVATE int cmdtail(drive, sector, count)
! int drive;
long sector;
+ int count;
{
***************
*** 269,272 ****
return(ERROR);
! DMA->dma_data = (short) (((drive&1)<<5) | (((int)(sector>>16))&0x1F));
! DMA->dma_mode = FDC | HDC | A0;
if (poll() != OK)
--- 316,318 ----
return(ERROR);
! dmawcmd((short) (((drive&1)<<5) | (((int)(sector>>16))&0x1F)), FDC | HDC | A0);
if (poll() != OK)
***************
*** 273,276 ****
return(ERROR);
! DMA->dma_data = (short) ((int)sector >> 8);
! DMA->dma_mode = FDC | HDC | A0;
if (poll() != OK)
--- 319,321 ----
return(ERROR);
! dmawcmd((short) ((int)sector >> 8), FDC | HDC | A0);
if (poll() != OK)
***************
*** 277,280 ****
return(ERROR);
! DMA->dma_data = (short) sector;
! DMA->dma_mode = FDC | HDC | A0;
if (poll() != OK)
--- 322,324 ----
return(ERROR);
! dmawcmd((short) sector, FDC | HDC | A0);
if (poll() != OK)
***************
*** 281,284 ****
return(ERROR);
! DMA->dma_data = (short) count;
! DMA->dma_mode = FDC | HDC | A0;
if (poll() != OK)
--- 325,327 ----
return(ERROR);
! dmawcmd((short) count, FDC | HDC | A0);
if (poll() != OK)
***************
*** 291,293 ****
*===========================================================================*/
! PRIVATE poll()
{
--- 334,336 ----
*===========================================================================*/
! PRIVATE int poll()
{
***************
*** 306,314 ****
! PRIVATE hdcint()
{
! PRIVATE message intmess;
! intmess.m_type = DISKINT;
! interrupt(WINCHESTER, &intmess);
}
! #endif ATARI_ST
--- 349,387 ----
! PRIVATE void hdcint()
{
! interrupt(WINCHESTER);
! }
! #ifdef CLOCKS
! #include <sgtty.h>
! #define XFERSIZE 13
! /*===========================================================================*
! * do_ioctl *
! *===========================================================================*/
! PRIVATE int do_ioctl(mp)
! register message *mp;
! {
! register phys_bytes address;
! register struct proc *rp;
! int r;
!
! rp = proc_addr(mp->PROC_NR);
! address = umap(rp, D, (vir_bytes) mp->POSITION, (vir_bytes) XFERSIZE);
! switch(mp->TTY_REQUEST) {
! case DC_RBMS100:
! case DC_RBM